//
//  LJJThirdLoginView.m
//  shopTest
//
//  Created by 梁佳佳 on 2016/11/14.
//  Copyright © 2016年 梁佳佳. All rights reserved.
//

#import "LJJThirdLoginView.h"

@interface LJJThirdLoginView ()

@property (strong, nonatomic) UIButton *qqLoginBtn;              /** qq登录button */
@property (strong, nonatomic) UIButton *WXLoginBtn;              /** 微信登陆button */
@property (strong, nonatomic) UIButton *sinaLoginBtn;              /** 新浪登录 */
@property (strong, nonatomic) UILabel *firstLogin;              /** 一键登录 */
@property (strong, nonatomic) UIView *lineView;              /** 分割线 */

@end


@implementation LJJThirdLoginView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.lineView];
        [self addSubview:self.firstLogin];
        [self addSubview:self.qqLoginBtn];
        [self addSubview:self.sinaLoginBtn];
        [self addSubview:self.WXLoginBtn];
    }
    return self;
}
- (void)layoutSubviews{
    [super layoutSubviews];
    __weak typeof (self) weakSelf = self;
    [_firstLogin mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80, 20));
        make.centerX.equalTo(weakSelf.mas_centerX);
        make.top.equalTo(weakSelf.mas_top);
    }];
    [_WXLoginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.firstLogin.mas_bottom).offset(20);
        make.size.mas_equalTo(CGSizeMake(45, 45));
        make.centerX.equalTo(weakSelf.mas_centerX);
    }];
    [_qqLoginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.firstLogin.mas_bottom).offset(20);
        make.size.mas_equalTo(CGSizeMake(45, 45));
        make.right.equalTo(weakSelf.WXLoginBtn.mas_left).offset(-(WIDTH-135)/4);
    }];
    [_sinaLoginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.firstLogin.mas_bottom).offset(20);
        make.size.mas_equalTo(CGSizeMake(45, 45));
        make.left.equalTo(weakSelf.WXLoginBtn.mas_right).offset((WIDTH-135)/4);
    }];
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weakSelf.firstLogin.mas_centerY);
        make.height.equalTo(@1);
        make.left.equalTo(weakSelf.mas_left).offset(16);
        make.right.equalTo(weakSelf.mas_right).offset(-16);
    }];
}
#pragma mark -
#pragma mark - method
- (void)qqRegistMehod:(UIButton *)sender
{
    if(_qqregistBlock){
        _qqregistBlock();
    }
}
#pragma mark -
#pragma mark - lazy method
- (UILabel *)firstLogin{
    if (!_firstLogin) {
        _firstLogin = [[UILabel alloc]init];
        _firstLogin.text = @"一键登录";
        _firstLogin.textColor = RGB(190, 190, 190, 1);
        _firstLogin.backgroundColor = MAINCOLOR;
        _firstLogin.textAlignment = NSTextAlignmentCenter;
        _firstLogin.font = [UIFont systemFontOfSize:16.0];
    }
    return _firstLogin;
}

- (UIButton *)qqLoginBtn{
    if (!_qqLoginBtn) {
        _qqLoginBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_qqLoginBtn setImage:[UIImage imageNamed:@"登录界面qq登陆"] forState:(UIControlStateNormal)];
        [_qqLoginBtn addTarget:self action:@selector(qqRegistMehod:) forControlEvents:(UIControlEventTouchUpInside)];
    }
    return _qqLoginBtn;
}

- (UIButton *)WXLoginBtn{
    if (!_WXLoginBtn) {
        _WXLoginBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_WXLoginBtn setImage:[UIImage imageNamed:@"登录界面微信登录"] forState:(UIControlStateNormal)];
    }
    return _WXLoginBtn;
}

- (UIButton *)sinaLoginBtn{
    if (!_sinaLoginBtn) {
        _sinaLoginBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_sinaLoginBtn setImage:[UIImage imageNamed:@"登陆界面微博登录"] forState:(UIControlStateNormal)];
    }
    return _sinaLoginBtn;
}

- (UIView *)lineView{
    if (!_lineView) {
        _lineView = [[UILabel alloc]init];
        _lineView.backgroundColor = RGB(190, 190, 190, 1);
    }
    return _lineView;
}

@end
